package com.google.code.mylyn.rtc.ui.wizard;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.mylyn.tasks.core.RepositoryStatus;
import org.eclipse.mylyn.tasks.core.RepositoryTemplate;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.ui.wizards.AbstractRepositorySettingsPage;
import org.eclipse.swt.widgets.Composite;

import com.google.code.mylyn.rtc.core.RtcCorePlugin;

public class RtcRepositorySettingsPage extends AbstractRepositorySettingsPage {

	public RtcRepositorySettingsPage(TaskRepository taskRepository) {
		super("Rtc Repository Settings", "Settings for Rtc Repository", taskRepository);
		setNeedsAnonymousLogin(false);
		setNeedsEncoding(false);
		setNeedsTimeZone(false);
		setNeedsAdvanced(false);
		setNeedsProxy(false);
		setNeedsAdvanced(false);
	}

	@Override
	public void createControl(Composite parent) {
		super.createControl(parent);
		addRepositoryTemplatesToServerUrlCombo();
	}

	@Override
	protected void repositoryTemplateSelected(RepositoryTemplate template) {
		repositoryLabelEditor.setStringValue(template.label);
		setUrl(template.repositoryUrl);
		setUserId("user");
		setPassword("pass");
		
		getContainer().updateButtons();
	}
	
	@Override
	public String getConnectorKind() {
		return RtcCorePlugin.CONNECTOR_KIND;
	}

	@Override
	protected void createAdditionalControls(Composite parent) {
		// TODO Auto-generated method stub

	}

	@Override
	protected boolean isValidUrl(String url) {
		return url != null && url.trim().length() > 0;
	}

	@Override
	protected Validator getValidator(TaskRepository repository) {
		return new RtcValidator();
	}

	@Override
	protected void validateSettings() {
		// TODO Auto-generated method stub
		super.validateSettings();
	}
	
	/**
	 * @author rsvalerio
	 */
	public class RtcValidator extends Validator{

		@Override
		public void run(IProgressMonitor monitor) throws CoreException {
			throw new CoreException(RepositoryStatus.createStatus("teste", IStatus.ERROR, RtcCorePlugin.PLUGIN_ID, Messages.error_not_yet_implemented));
		}
		
	}
	
	
}
